﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class RandomRank : MonoBehaviour {

    private List<string> NameList = new List<string>();
    private List<string> TempNameList = new List<string>();
    private Text[] _textList;
    public Button btn;

    private int Step = 0;

	void Start () {

        Screen.SetResolution(1200, 675, false);

        NameList.Add("Salieri");
        NameList.Add("飘雪落华");
        NameList.Add("让·K·利安");
        NameList.Add("智异山小沈");
        NameList.Add("Mozalic");
        NameList.Add("灯下黑");
        NameList.Add("Eden");
        NameList.Add("Trishula,Dragon");
        NameList.Add("小惰小惰");
        NameList.Add("键ノ往人");
        NameList.Add("光玉瞬逝时");
        NameList.Add("0.0");
        NameList.Add("漫，天，影");
        NameList.Add("零星刹那");
        NameList.Add("鱼");
        NameList.Add("琲");
        NameList.Add("十年后的8月");
        NameList.Add("Someone I'll forg");
        NameList.Add("爱咿！你好~~");
        NameList.Add("ウニ");
        NameList.Add("Een");
        NameList.Add("Rokka");
        NameList.Add("小天");
        NameList.Add("L丶Lawliet");
        NameList.Add("北方栖姬");
        NameList.Add("Mohr");
        NameList.Add("活号");
        NameList.Add("千歌音HM");

        _textList = GetComponentsInChildren<Text>();
        TempNameList.AddRange(NameList);

        btn.onClick.AddListener(() =>
        {
            if (Step >= _textList.Length)
            {
                Step = 0;
                TempNameList.AddRange(NameList);
                foreach (var text in _textList)
                    text.text = "";
                return;
            }

            //抽签
            int num = Random.Range(0, TempNameList.Count);
            _textList[Step++].text = TempNameList[num];
            TempNameList.RemoveAt(num);
        });
    }
}
